<!-- 酒店库存管理 -->
<template>
    <el-container>
        <el-main class="base_main_content">
            <div class="base_screen_header">
                <span></span>
                <el-form :inline="true" class="base_search_form" @submit.prevent>
                    <el-form-item>
                        <el-select v-model="base" @change="searchBase" placeholder="请选择基地" clearable>
                            <el-option v-for="(item, index) in baseOptions" :key="index" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-input v-model="name" @keyup[native].enter="searchName" @change="searchName" placeholder="酒店名称"
                            clearable :suffix-icon="Search" />
                    </el-form-item>
                </el-form>
            </div>
            
            <HotelStockTable type="manager" route="hotelmanager" @statusData="statusData" />
        </el-main>
    </el-container>
</template>

<script setup>
import HotelStockTable from '@com/hotel/HotelStockTable.vue'
import StatusBar from '@com/StatusBar.vue';
import { ref, reactive } from 'vue'
import { Search } from '@element-plus/icons-vue'
import useRoute from "@util/router";
import CategoryManager from '@com/CategoryManager.vue';
import $ from "@util/base"
import configApi from "@api/config"
import api from "@api/hotel"

const route = useRoute()

const categoryConfig = {
    type: 'hotel'
}

const baseOptions = ref([])

getConfig()

function getConfig() {
    configApi.base(val => {
        baseOptions.value = val
    })
}

const statusList = reactive([{
    label: '全部',
    value: 1,
    total: 0
}, {
    label: '已上架',
    value: 3,
    total: 0
}, {
    label: '已下架',
    value: 2,
    total: 0
}])

const base = ref(route.query().base || '')
const name = ref(route.query().name || '')

function statusData(val) {
    statusList.forEach((e, i) => { e.total = val[i] })
}

function searchBase(val) {
    route.replaceQuery('base', val)
}

function searchName(val) {
    route.replaceQuery('name', val)
}

function addGoods() {
    route.push('/goodsdetails')
}

function getExport() {
    let routeQuery = route.query()
    api.managerExport({
        categoryCode: routeQuery.c,
        shopCode: routeQuery.base,
        name: routeQuery.name,
        status: routeQuery.status,
    }, val => {
        $.download(val.url, "酒店管理列表导出")
    })
}
</script>

<style lang="scss"></style>
